<%@ page language="java" import="com.alibaba.fastjson.JSONArray" pageEncoding="UTF-8" %>
<%@ page import="com.alibaba.fastjson.JSONObject" %>
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="java.util.LinkedHashMap" %>
<%--获取发票信息--%>
<%
    JSONObject dataJson = new JSONObject();
    RecordSet rs = new RecordSet();
    try {
        String fphms = Util.null2String(request.getParameter("fphms"));
        String newfphms = "";
        String [] fphmsArr = fphms.split(",");
        for (String fphm:fphmsArr) {
            newfphms+="".equals(newfphms)?"'"+fphm+"'":",'"+fphm+"'";
        }
        String ids = "";
        JSONArray jsonArr = new JSONArray();
        rs.executeQuery("select id,invoicenumber from fnainvoiceledger where invoicenumber in ("+newfphms+")" +
                " order by instr('"+fphms+"',invoicenumber)");
        while (rs.next()){
            JSONObject json = new JSONObject(new LinkedHashMap());
            String id = Util.null2String(rs.getString("id"));
            String invoicenumber = Util.null2String(rs.getString("invoicenumber"));
            json.put("id", id);
            json.put("name", invoicenumber);
            jsonArr.add(json);
            ids += "".equals(ids) ? id : "," + id;
        }

        dataJson.put("ids", ids);
        dataJson.put("datalist", jsonArr);
    } catch (Exception e) {
        e.printStackTrace();
    }
    out.print(dataJson.toJSONString());
%>
